package may.naing.sysadmin.factory;

import may.naing.sysadmin.dao.IMember;
import may.naing.sysadmin.daoimpl.*;

import java.sql.*;
import javax.naming.*;
import javax.sql.DataSource;

public class SystemAdministrationDAOFactoryImpl extends SystemAdministrationDAOFactory  {
	static Connection conn;
	
	public static Connection createConnection(){
		InitialContext cxt;
		try {
			cxt = new InitialContext();
			DataSource ds = (DataSource) cxt.lookup( "java:/comp/env/jdbc/systemadministration" );
			try {
				conn = ds.getConnection();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} catch (NamingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		return conn;
	}
	
	@Override
	IMember getMemberDAO() {
		// TODO Auto-generated method stub
		return new MemberDAOImpl(conn)  ;
	}

}
